<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__role">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item>
          <el-input size="mini" v-model="dataForm.postCode" :placeholder="$t('post.postCode')" clearable></el-input>
        </el-form-item>
		<el-form-item>
		  <el-input size="mini" v-model="dataForm.postName" :placeholder="$t('post.postName')" clearable></el-input>
		</el-form-item>
		<el-form-item>
		  <el-input size="mini" v-model="dataForm.postType" :placeholder="$t('post.postType')" clearable></el-input>
		</el-form-item>
		
		<el-form-item>
		  <el-select size="mini" v-model="dataForm.status" clearable  placeholder="状态" >
		      <el-option :key="1":label="$t('status1')":value="1"> </el-option>
			  <el-option :key="0":label="$t('status0')":value="0"> </el-option>
		    </el-select>
		</el-form-item>
		
        <el-form-item>
          <el-button size="mini" v-if="$hasPermission('post:page')" @click="getDataList()">{{ $t('query') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button size="mini" v-if="$hasPermission('post:add')" type="primary" @click="addHandle()">{{ $t('add') }}</el-button>
        </el-form-item>
       <!-- <el-form-item>
          <el-button v-if="$hasPermission('post:del')" type="danger" @click="delHandle()">{{ $t('deleteBatch') }}</el-button>
        </el-form-item> -->
      </el-form>
      <el-table
        v-loading="dataListLoading"
        :data="dataList"
        border
        @selection-change="dataListSelectionChangeHandle"
        @sort-change="dataListSortChangeHandle"
        style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column prop="postCode" :label="$t('post.postCode')" header-align="center" align="center"></el-table-column>
		<el-table-column prop="postName" :label="$t('post.postName')" header-align="center" align="center"></el-table-column>
		<el-table-column prop="postRank" :label="$t('post.postRank')" header-align="center" align="center" :show-overflow-tooltip="true"></el-table-column>
		<el-table-column prop="status" :label="$t('status')" header-align="center" align="center">
		  <template slot-scope="scope">
		    <el-tag v-if="scope.row.status === 1" size="small">{{ $t('status1') }}</el-tag>
			 <el-tag type="danger" v-if="scope.row.status === 0" size="small">{{ $t('status0') }}</el-tag>
		  </template>
		</el-table-column>
		<el-table-column prop="remark" :label="$t('remark')" header-align="center" align="center" :show-overflow-tooltip="true"></el-table-column>
		<el-table-column prop="postType" :label="$t('post.postType')" header-align="center" align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="createUser" :label="$t('createUser')"  header-align="center" align="center" width="180"></el-table-column>
		<el-table-column prop="createTime" :label="$t('createTime')"  header-align="center" align="center" width="180"></el-table-column>
		<el-table-column prop="updateTime" :label="$t('updateTime')"  header-align="center" align="center" width="180"></el-table-column>
        <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
          <template slot-scope="scope">
            <el-button v-if="$hasPermission('post:modify')" type="text" size="small" @click="modifyHandle(scope.row,new Object())">{{ $t('update') }}</el-button>
            <el-button v-if="$hasPermission('post:del')" type="text" size="small" @click="delHandle(scope.row.postId)">{{ $t('delete') }}</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="pageNo"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './post-add-or-update'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/pc/post/page',
        getDataListIsPage: true,
        deleteURL: '/pc/post/del',
        deleteIsBatch: false
      },
      dataForm: {
        postCode: '',
		postName: '',
		postType: '',
		status: null
      }
    }
  },
  components: {
    AddOrUpdate
  }
}
</script>
